﻿Imports System.IO

Public Class XtraReport_Phieuthu
    Dim vtongtien As Double
    Dim vsophieu, vDonvi, vngaythang, vdiachiphieu As String
    Private Sub XtraReportBacSi_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles Me.BeforePrint
        'xử lý lấy hình từ database
        Dim byteBLOBData As [Byte]() = New [Byte]() {}
        byteBLOBData = DirectCast(Me.VLogoTableAdapter.GetData.Rows(0).Item(0), [Byte]())
    Dim stmBLOBData As New MemoryStream(byteBLOBData)
    'gán lại vô xrpicture để hiện hình ảnh
        Me.XrPictureBox1.Image = Image.FromStream(stmBLOBData)
    'Me.XrPictureBox1.Image = stmBLOBData.ToArray()
    'lấy dữ liệu từ db lên 
    Dim tendoanhnghiep As String = Me.VLogoTableAdapter.GetData().Rows(0).Item(1)
    Dim diachidoanhnghiep As String = Me.VLogoTableAdapter.GetData().Rows(0).Item(2)
    'gán lại giá trị cho parameter
        Me.Ten.Value = tendoanhnghiep
        Me.DiaChi.Value = diachidoanhnghiep
        Me.Sophieu.Value = vsophieu
        Me.donvi.Value = vDonvi
        Me.Diachi_phieu.Value = vdiachiphieu
        Me.Lydo.Value = "Thu tiền của " & vDonvi
        Me.Tongtien.Value = vtongtien
        Me.Tienchu.Value = moduleUtils.NumToText(vtongtien) & " đồng."
        Me.ngaythang.Value = vngaythang

    'add vô report
        Me.Parameters.Add(Ten)
        Me.Parameters.Add(DiaChi)

        Me.Parameters.Add(Sophieu)
        Me.Parameters.Add(donvi)
        Me.Parameters.Add(Diachi_phieu)
        Me.Parameters.Add(Lydo)
        Me.Parameters.Add(Tongtien)
        Me.Parameters.Add(Tienchu)
        Me.Parameters.Add(ngaythang)
    
    End Sub
    Public Sub setSophieu(ByVal s As String)
        vsophieu = s
    End Sub
    Public Sub setTongtien(ByVal s As Double)
        vtongtien = s
    End Sub
    Public Sub setDonvi(ByVal s As String)
        vDonvi = s
    End Sub
    Public Sub setNgaythang(ByVal s As String)
        vngaythang = s
    End Sub
    Public Sub setDiaChiPhieu(ByVal s As String)
        vdiachiphieu = s
    End Sub
End Class